const Router = require("koa-router");
const router = new Router({ prefix: "/software" });
const { validator } = require("../MiddleWare/validator");
const { FormatError } = require("../Constant/err.type");
module.exports = router;

const {
  createsoft,
  upload,
  removesoft,
  findAllsoft,
  updatesoft,
  restoresoft,
} = require("../Controller/software.controller");
// 图片上传接口
router.post("/upload", upload);
// 添加软件信息接口
router.post(
  "/",
  validator(
    { softName: "string", iconUrl: "string", softMenuInfo: "array" },
    FormatError
  ),
  createsoft
);
//获得已经注册的软件接口
router.get("/", findAllsoft);
// 软件软删除接口
router.post("/:id/off", removesoft);
// 软件复原接口
router.post("/:id/on", restoresoft);
// 修改软件信息接口
router.post(
  "/:id/update",
  validator(
    {
      softName: { type: "string", require: true },
      iconUrl: { type: "string", require: true },
      softMenuInfo: { type: "array", require: true },
    },
    FormatError
  ),
  updatesoft
);
module.exports = router;
